const { goods, ad, newproducts } = require('../../utils/tempdata.js');
var app = getApp();
Page({
  onShareAppMessage: function (options) {
    var that = this;
    // 设置菜单中的转发按钮触发转发事件时的转发内容
    var shareObj = {
      title: "呗丝咪",        // 默认是小程序的名称(可以写slogan等)
      path: '/pages/index/index',        // 默认是当前页面，必须是以‘/’开头的完整路径
      imgUrl: '',     //自定义图片路径，可以是本地文件路径、代码包文件路径或者网络图片路径，支持PNG及JPG，不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
    };

    // 来自页面内的按钮的转发
    if (options.from == 'button') {
      var eData = options.target.dataset;
      shareObj.path = '/pages/videocenter/videodetail/videodetail?shareid=' + this.data.videoinfo.id;
    }
    // 返回shareObj
    return shareObj;
  },
  /**
   * 页面的初始数据
   */
  data: {
    swiperinfo: {
      hgt: 0,
      indicatorDots: true,
      autoplay: true,
      circular: true,
      interval: 5000,
      duration: 500,
    },
    listhgt: 0
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        var swiper_hgt = 400 * res.windowWidth / 800;
        var swiperinfo = that.data["swiperinfo"];
        swiperinfo.hgt = swiper_hgt;
        that.setData({
          "swiperinfo": swiperinfo
        });
      },
    });

    // app.showLoading();
  },
  checkLogin: function () {
    
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.loadIndex();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.stopPullDownRefresh();
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    // console.log("bottom");
  },
  loadIndex: function () {
    this.loadIndexCallBack();
  },
  loadIndexCallBack: function (res = null) {
    var tjimgs = goods;
    var imgs = ad;
    var newpros = newproducts;
    this.setData({
      tjimgs: tjimgs,
      imgs: imgs,
      nproducts:newpros
    });
  },
  bannerTap: function (event) {
    // var goodsid = event.currentTarget.dataset.bannerlink;
    // wx.navigateTo({
    //   url: '../store/goodsdetail/goodsdetail?goodsid=' + goodsid,
    // });
    return;
    wx.navigateTo({
      url: '../store/goodsdetail/goodsdetail?goodsid=000',
    });
  },
  toGoodsDetail: function (event) {
    // var goodsid = event.currentTarget.dataset.goodsid;
    // wx.navigateTo({
    //   url: '../store/goodsdetail/goodsdetail?goodsid=' + goodsid,
    // });
    return;
    wx.navigateTo({
      url: '../store/goodsdetail/goodsdetail?goodsid=000',
    });
  },
  toFind:function(event){
    wx.switchTab({
      url: '../videocenter/videocenter',
    });
  }
})